<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <input type="text" id="int1" placeholder="输入数字"><span id="main1"></span>
    <br>
    <input type="text" id="int2" placeholder="输入汉字"><span id="main2"></span>
    <br>
    <input type="text" id="int3" placeholder="输入英文"><span id="main3"></span>
    <br>
    <input type="text" id="int4" placeholder="输入数字字母下滑线"><span id="main4"></span>
    <br>
    <input type="text" id="int5" placeholder="输入汉字数字字母下滑线"><span id="main5"></span>
    <br>
    <input type="text" id="int6" placeholder="输入数字汉字"><span id="main6"></span>
    <br>
    <input type="text" id="int7" placeholder="输入5位数字"><span id="main7"></span>
    <br>
    <input type="text" id="int8" placeholder="输入5位数字字母下划线"><span id="main8"></span>
    <br>
    <input type="text" id="int9" placeholder="检查是否包含@符号"><span id="main9"></span>
    <br>
    <input type="text" id="int10" placeholder="检查是否手机号"><span id="main10"></span>
    <br>
    <input type="text" id="int11" placeholder="检查邮箱"><span id="main11"></span>
    <br>
    <input type="text" id="int12" placeholder="检查身份证号"><span id="main12"></span>
    <br>
    <input type="text" id="int13" placeholder="检查是否是url地址"><span id="main13"></span>
    <br>
</body>
<script>
    // 数字
    document.getElementById('int1').onblur = function () {
        var reg1 = /^\d+$/g
        if (reg1.test(this.value)) {
            main1.innerHTML = '√'
        } else {
            main1.innerHTML = '×'
        }
    }

    // 汉字
    document.getElementById('int2').onblur = function () {
        var reg2 = /^[\u4e00-\u9fa5]+$/g
        if (reg2.test(this.value)) {
            main2.innerHTML = '√'
        } else {
            main2.innerHTML = '×'
        }
    }

    // 英文
    document.getElementById('int3').onblur = function () {
        var reg3 = /^[a-zA-Z]+$/
        if (reg3.test(this.value)) {
            main3.innerHTML = '√'
        } else {
            main3.innerHTML = '×'
        }
    }

    // 数字字母下滑线
    document.getElementById('int4').onblur = function () {
        var reg4 = /^\w+$/
        if (reg4.test(this.value)) {
            main4.innerHTML = '√'
        } else {
            main4.innerHTML = '×'
        }
    }

    // 汉字数字字母下滑线
    document.getElementById('int5').onblur = function () {
        var reg5 = /^([\u4e00-\u9fa5]|\w)+$/
        if (reg5.test(this.value)) {
            main5.innerHTML = '√'
        } else {
            main5.innerHTML = '×'
        }
    }

    // 数字汉字
    document.getElementById('int6').onblur = function () {
        var reg6 = /^([\u4e00-\u9fa5]|\d)+$/
        if (reg6.test(this.value)) {
            main6.innerHTML = '√'
        } else {
            main6.innerHTML = '×'
        }
    }

    // 5位数字
    document.getElementById('int7').onblur = function () {
        var reg7 = /^\d{5}$/
        if (reg7.test(this.value)) {
            main7.innerHTML = '√'
        } else {
            main7.innerHTML = '×'
        }
    }

    // 5位数字字母下划线
    document.getElementById('int8').onblur = function () {
        var reg8 = /^\w{5}$/
        if (reg8.test(this.value)) {
            main8.innerHTML = '√'
        } else {
            main8.innerHTML = '×'
        }
    }

    // 检查是否包含@符号
    document.getElementById('int9').onblur = function () {
        var reg9 = /@/
        if (reg9.test(this.value)) {
            main9.innerHTML = '√'
        } else {
            main9.innerHTML = '×'
        }
    }

    // 检查是否手机号
    document.getElementById('int10').onblur = function () {
        var reg10 = /^1[2-9]\d{9}$/
        if (reg10.test(this.value)) {
            main10.innerHTML = '√'
        } else {
            main10.innerHTML = '×'
        }
    }

    // 检查邮箱
    document.getElementById('int11').onblur = function () {
        // var reg11 = /^([a-zA-Z]|[0-9])(\w|\-)+@[a-zA-Z0-9]+\.([a-zA-Z]{2,4})$/
        var sun = this.value
        var reg11 = /^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/;
        if (reg11.test(sun)) {
            main11.innerHTML = '√'
        } else {
            main11.innerHTML = '×'
        }
    }

    // 检查身份证号
    document.getElementById('int12').onblur = function () {
        var reg12 = /^([1-9]\d{13}[\d|x]|[1-9]\d{16}[\d|x])$/i
        if (reg12.test(this.value)) {
            main12.innerHTML = '√'
        } else {
            main12.innerHTML = '×'
        }
    }






</script>
</html>